package berlinatyourfingertips.ua.apis;

import berlinatyourfingertips.ua.UAListener;
import berlinatyourfingertips.ua.UAResult;
import berlinatyourfingertips.ua.UAResultSet;
import berlinatyourfingertips.ua.UAUpdating;

public class UAUpdatingTwitter extends UAUpdating {
	
	private UATwitter twitter = new UATwitter();
	
	private UAResultSet lastResult = new UAResultSet();
	
	public UAUpdatingTwitter(UAListener listener, int updateInterval) {
		super(listener, updateInterval);
	}
	
	@Override
	public void run() {
		UAResultSet currentResult = twitter.getAllAtPosition(52.31f, 13.20f);
		
		for(UAResult r : currentResult) {
			if(!lastResult.idExists(r.getId())) {
				listener.newElement(r);
				lastResult.add(r);
			}
		}
	}

}
